package com.cjbdi.dao;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.cjbdi.entity.Message;

@Repository
public interface MessageRepository extends JpaRepository<Message, Long> {
	
	@Transactional
    @Modifying(clearAutomatically = true)
    @Query(value = "delete from message where id=:id",nativeQuery = true)
    Integer delete(@Param("id")int id);
    
    @Query(value = "select * from message where case when :description!=''then description like '%'||:description||'%' else 1=1 end and case when :fymc!='' then fymc like '%'||:fymc||'%' else 1=1 end" , nativeQuery = true)
    Page<Message> getPageByParam(@Param("description") String description,@Param("fymc") String fymc,Pageable pageable);
    
    
}
